import 'package:flutter/material.dart';
import 'package:pin_chat/pin_chat.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  PinChat.configure(
    clientKey: 'fangho_imkit_0412_2018_001_clientkey',
    serverUrl: 'https://chat.fangho.com',
  );
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  void _startChat() {
    PinChat.connect(userId: '123456').then((value) {
      PinChat.goChatRoomList();
    });
    // PinChat.connectAndStartChat(userId: '123456', toUserId: 'trading_platform_id', nickname: '雨泽');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: TextButton(
            child: const Text('Start Chat'),
            onPressed: _startChat,
          ),
        ),
      ),
    );
  }
}
